package thread;

/**
 * 当线程处于sleep方法时，调用interrrupt方法后，线程会抛出InterruptedException异常，并且中断状态会重置为false
 */
public class SleepDemo2 {
    public static void main(String[] args) {


        Thread main=Thread.currentThread();
        //
        Thread huang=new Thread(){
            public void run(){
                System.out.println(getName()+":正在打游戏~~~~,倒一个，倒一个");
                for (int i = 0; i < 5; i++) {
                    System.out.println(getName()+":倒一个~~~~");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(getName()+":游戏输了，主角死了，红温了");
                System.out.println(getName()+":TMD一滴血都打不过，我都打倒俩了，会不会玩啊，大叫压力队友");
                main.interrupt();//中断lin线程的睡眠阻塞
            }
        };
        huang.start();


        try {
            System.out.println(main.getName()+":睡觉了~~~~");
            Thread.sleep(1000000000);
        } catch (InterruptedException e) {
            System.out.println(main.getName()+":被中断了~~~~");
        }

        System.out.println(main.getName()+":醒来了~~~~");

        //
        Thread lin=new Thread(){
            public void run(){

            }
        };



        //lin.start();

    }
}
